package view.render.monster
{
	import enums.main.UISize;
	import enums.monster.MonsterEnum;
	
	import feathers.controls.Label;
	
	import model.vo.monster.LMonsterMeatQualityVo;
	
	import view.render.BaseScrollerItem;
	
	
	/**
	 * 大型怪物-肉质列表item
	 * @author £iang
	 * 
	 */	
	public class LMonsterMeatListItem extends BaseScrollerItem
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 斩击信息 */
		public var cutLabel:Label;
		/** 打击信息 */
		public var beatLabel:Label;
		/** 射击信息 */
		public var shotLabel:Label;
		/** 火属性信息 */
		public var fireLabel:Label;
		/** 水属性信息 */
		public var waterLabel:Label;
		/** 雷属性信息 */
		public var thunderLabel:Label;
		/** 冰属性信息 */
		public var iceLabel:Label;
		/** 龙属性信息 */
		public var dragonLabel:Label;
		/** 眩晕值信息 */
		public var dizzyLabel:Label;
		/** 硬直信息 */
		public var fearLabel:Label;
		/** 猎虫吸取信息 */
		public var bugLabel:Label;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initializeOther():void
		{
			super.initializeOther();
			cutLabel = new Label();
			cutLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( cutLabel );
			
			beatLabel = new Label();
			beatLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( beatLabel );
			
			shotLabel = new Label();
			shotLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( shotLabel );
			
			fireLabel = new Label();
			fireLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( fireLabel );
			
			waterLabel = new Label();
			waterLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( waterLabel );
			
			thunderLabel = new Label();
			thunderLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( thunderLabel );
			
			iceLabel = new Label();
			iceLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( iceLabel );
			
			dragonLabel = new Label();
			dragonLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( dragonLabel );
			
			dizzyLabel = new Label();
			dizzyLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( dizzyLabel );
			
			fearLabel = new Label();
			fearLabel.textRendererProperties.wordWrap = true;
			scollerContainer.addChild( fearLabel );
			
			bugLabel = new Label();
			bugLabel.textRendererProperties.wordWrap = true;
			bugLabel.textRendererProperties.isHTML = true;
			scollerContainer.addChild( bugLabel );
		}
		
		/**
		 * 调整组件 
		 * 
		 */		
		override protected function draw():void
		{
			var labelY:Number = ( _itemH - 
				43 ) / 2 * UISize.DPI_SCALE;
			var leftPadding:Number = UISize.TITLE_PADDING_LEFT * UISize.DPI_SCALE;
			var firstLabelFullW:Number;
			
			firstLabel.x = leftPadding;
			firstLabelFullW = UISize.MAIN_W * _firstPercent;
			
			cutLabel.y = labelY;
			cutLabel.x = 0;
			cutLabel.width  = UISize.MAIN_W * 0.2;
			
			beatLabel.y = labelY;
			beatLabel.x = UISize.MAIN_W * 0.2;
			cutLabel.width  = UISize.MAIN_W * 0.2;
			
			shotLabel.y = labelY;
			shotLabel.x = UISize.MAIN_W * 0.4;
			shotLabel.width  = UISize.MAIN_W * 0.2;
			
			dizzyLabel.y = labelY;
			dizzyLabel.x = UISize.MAIN_W * 0.6;
			dizzyLabel.width  = UISize.MAIN_W * 0.2;
			
			fearLabel.y = labelY;
			fearLabel.x = UISize.MAIN_W * 0.8;
			fearLabel.width  = UISize.MAIN_W * 0.2;
			
			bugLabel.y = labelY;
			bugLabel.x = UISize.MAIN_W;
			bugLabel.width  = UISize.MAIN_W * 0.2;
			
			fireLabel.y = labelY;
			fireLabel.x = UISize.MAIN_W * 1.2;
			fireLabel.width  = UISize.MAIN_W * 0.12;
			
			waterLabel.y = labelY;
			waterLabel.x = UISize.MAIN_W * 1.32;
			waterLabel.width  = UISize.MAIN_W * 0.12;
			
			thunderLabel.y = labelY;
			thunderLabel.x = UISize.MAIN_W * 1.44;
			thunderLabel.width  = UISize.MAIN_W * 0.12;
			
			iceLabel.y = labelY;
			iceLabel.x = UISize.MAIN_W * 1.56;
			iceLabel.width  = UISize.MAIN_W * 0.12;
			
			dragonLabel.y = labelY;
			dragonLabel.x = UISize.MAIN_W * 1.68;
			dragonLabel.width  = UISize.MAIN_W * 0.12;
			
			scollerContainer.x = firstLabelFullW;
			scollerContainer.height = _itemH * UISize.DPI_SCALE;
			scollerContainer.width = UISize.MAIN_W - firstLabelFullW;
			
			this.width = UISize.MAIN_W;
			this.height = _itemH * UISize.DPI_SCALE;
		}
		
		/**
		 * 设置item数据 
		 * @param data 数据
		 * 
		 */		
		public function setData( data:LMonsterMeatQualityVo ):void
		{
			var physicalPoint:int = MonsterEnum.PHYSICAL_WEAKNESS_POINT;
			var attributePoint:int = MonsterEnum.ATTRIBUTE_WEAKNESS_POINT;
			
			firstLabel.text = data.part;
			
			if ( data.type && data.type != "" )
				firstLabel.text = "(" + data.type + ")" + data.part;
			
			cutLabel.text = data.cut;
			setLabelTextFormat( "cutLabel", data.cut, physicalPoint );
			beatLabel.text = data.beat;
			setLabelTextFormat( "beatLabel", data.beat, physicalPoint );
			shotLabel.text = data.shot;
			setLabelTextFormat( "shotLabel", data.shot, physicalPoint );
			fireLabel.text = data.fire;
			setLabelTextFormat( "fireLabel", data.fire, attributePoint );
			waterLabel.text = data.water;
			setLabelTextFormat( "waterLabel", data.water, attributePoint );
			thunderLabel.text = data.thunder;
			setLabelTextFormat( "thunderLabel", data.thunder, attributePoint );
			iceLabel.text = data.ice;
			setLabelTextFormat( "iceLabel", data.ice, attributePoint );
			dragonLabel.text = data.dragon;
			setLabelTextFormat( "dragonLabel", data.dragon, attributePoint );
			dizzyLabel.text = data.dizzy;
			fearLabel.text = data.fear;
			
			var color:String = data.bug;
			var colorText:String;
			
			switch(color)
			{
				case "红":
				{
					colorText = '<font color="#FF0000">红</font>';
					break;
				}
					
				case "白":
				{
					colorText = '<font color="#FFFFFF">白</font>';
					break;
				}
					
				case "橙":
				{
					colorText = '<font color="#FF8800">橙</font>';
					break;
				}
					
				case "绿":
				{
					colorText = '<font color="#00FF00">绿</font>';
					break;
				}
					
				default:
				{
					break;
				}
			}
			
			bugLabel.text = colorText;
		}
		
		/**
		 * 设置标签颜色 
		 * @param labelName label名
		 * @param dataName data属性名
		 * @param point 临界数值
		 * 
		 */		
		private function setLabelTextFormat( labelName:String, dataPoint:String, point:int ):void
		{
			if ( int( dataPoint ) >= point )
			{
				( this[ labelName ] as Label ).name = "importantContentLabel";
			}
		}
		
		
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构滚动条容器中的标签 
		 * 
		 */		
		protected override function disposeAnythingInContainer():void
		{
			disposeLabels( [
				"cut", "beat", "shot",
				"fire", "water", "thunder", 
				"ice", "dragon", "dizzy",
				"fear", "bug"
			] );
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function LMonsterMeatListItem()
		{
			super();
			_itemH = UISize.LMONSTER_MQ_ITEM_H;
			_firstPercent = 0.4;
			initialize();
		}
	}
}